package cate.game.play.skill.passive.god;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 敌方每有1个目标死亡恢复自身生命值的10%，每回合至多触发1次
 */
public class 贡品PH extends PassiveHandler {

	private double 恢复系数;

	//恢复系数=1000
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		恢复系数 = args.getWDouble("恢复系数", 0d);
	}

	private int lastRound;

	@Override
	public void onOtherDead(ActionCtx action, Fighter killer, Fighter deader) {
		if(skill.owner.isDead()){
			return;
		}
		if(deader.getTeam()==skill.owner.getTeam()){
			return;
		}
		if(lastRound>=action.getRound().index){
			return;
		}
		lastRound = action.getRound().index;
		skill.owner.attr.passiveHeal(action, skill.owner.attr.total().hpTotal()*恢复系数);
	}
}
